//package com.plian.system.task;
//
//import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.plian.system.entity.mt.TemporaryTaskDistribution;
//import com.plian.system.mapper.mt.TemporaryTaskDistributionMapper;
//import com.plian.system.service.mt.ITemporaryTaskDistributionService;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDate;
//import java.time.LocalDateTime;
//import java.time.temporal.ChronoField;
//import java.util.Date;
//import java.util.List;
//
///**
// * @Description: 临时任务下发状态自动修改定时任务
// * @Author husong
// * @Date 2023/2/21
// **/
//@Slf4j
//@Component
//@RequiredArgsConstructor
//public class TemporaryTaskDistributionTask {
//    private final TemporaryTaskDistributionMapper temporaryTaskDistributionMapper;
//    private final ITemporaryTaskDistributionService temporaryTaskDistributionService;
//
//    // 每天凌晨12点执行
//    @Scheduled(cron = "0 0 0 * * ? ")
//    // 测试用 每30执行一次
////    @Scheduled(cron = "0/30 * * * * ? ")
//    public void updateStatus(){
//        log.info("临时任务下发任务状态修改开始 ------------> " + LocalDateTime.now());
//        List<TemporaryTaskDistribution> tasks = temporaryTaskDistributionMapper.selectList(new LambdaQueryWrapper<TemporaryTaskDistribution>()
//                .eq(TemporaryTaskDistribution::getTaskStatus, "153002")
//                .lt(TemporaryTaskDistribution::getLimitTime, new Date()));
//        log.info("待修改的临时任务 ------------> " + JSONObject.toJSONString(tasks));
//        tasks.forEach(task -> {
//            task.setTaskStatus("153003");
//        });
//        temporaryTaskDistributionService.updateBatchById(tasks);
//        log.info("临时任务下发任务状态修改结束 ------------> " + JSONObject.toJSONString(tasks));
//    }
//
//}
